package com.bstek.handler;


import com.bstek.Result;
import com.bstek.urule.RuleException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author gehongbin@xdf.cn
 * 异常处理
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    private final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);



    @ExceptionHandler(value = RuleException.class)
    @ResponseBody
    public Result handerServiceException(HttpServletRequest req, RuleException e) {
        logger.warn("", e);
        return new Result("0", e.getMessage());
    }

}
